import request from '@/utils/request/security';
// import type { RouteRecordNormalized } from 'vue-router';
import { LoginInfo, UserRes } from './model/securityModel';

export function login(data: LoginInfo) {
  // return request.post<LoginRes>('/oauth/token', data);
  return request({
    method: 'post',
    url: '/api/oauth/user/token',
    auth: {
      username: 'procurement',
      password: 'Lcyxxhb.123',
    },
    data,
  });
}

export function logout() {
  return request.post('/api/oauth/logout');
}

export function getUserInfo() {
  return request.get<UserRes>('/api/system/permission/info');
}

// export function getMenuList() {
//   return request.post<RouteRecordNormalized[]>('/api/user/menu');
// }

// 单点登录
export function ssoLogin(token: string) {
  return request({
    method: 'get',
    url: '/api/oauth/sso/token',
    auth: {
      username: 'procurement',
      password: 'Lcyxxhb.123',
    },
    params: { token },
  });
}

// 解析ticket, 得到token
export function validateTicket(ticket: string) {
  return request({
    method: 'get',
    url: '/api/oauth/sso/ticket/validation',
    params: { ticket },
  });
}
